package com.leetcode;

import java.util.Scanner;

/**
 * 将一个英文语句以单词为单位逆序排放。例如“I am a boy”，逆序排放后为“boy a am I”
 * <p>
 * 所有单词之间用一个空格隔开，语句中除了英文字母外，不再包含其他字符
 */
public class 句子逆序 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String[] split = str.split(" ");
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = (split.length - 1); i >= 0; i--) {
            stringBuilder.append(split[i]).append(" ");
        }
        System.out.println(stringBuilder);
    }
}
